package com.jkoss.biz.imp.jy;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.jkoss.biz.jy.JyCompsBiz;
import com.jkoss.dao.jy.JiuyeGSMapper;
import com.jkoss.pojo.jy.JiuyeGS;
import com.jkoss.pojo.jy.JiuyeGSExample;
import com.jkoss.tool.Page;
@Component
public class JyCompsBizImpl  implements JyCompsBiz{
    
	@Autowired
	private JiuyeGSMapper jyGsDao;
	
	@Override
	public List<JiuyeGS> listGs(Page<JiuyeGS> page) {
		
		return jyGsDao.listGs(page);
	}

	@Override
	public JiuyeGS findByJyid(Integer jyid) {
		
		return jyGsDao.findByJyid(jyid);
	}

	@Override
	@Transactional
	public String addGs(JiuyeGS gs) {
		
		return jyGsDao.insert(gs)>0?"添加成功":"添加失败";
	}

	@Override
	@Transactional
	public String delGs(Integer jyid) {
		
		return jyGsDao.deleteByPrimaryKey(jyid)>0?"删除成功":"删除失败";
	}

	@Override
	@Transactional
	public String upGs(JiuyeGS g) {
		
		return jyGsDao.updateByPrimaryKey(g)>0?"修改成功":"修改失败";
	}

	@Override
	public List<JiuyeGS> listAll() {
		
		return  jyGsDao.findAll();
	}

	@Override
	public JiuyeGS findTheSame(String jyname, String jyaddrss) {
		
		JiuyeGSExample jiuyeGSExample=new JiuyeGSExample();
		
		com.jkoss.pojo.jy.JiuyeGSExample.Criteria criteria=jiuyeGSExample.createCriteria();
		
		criteria.andJyaddrssEqualTo(jyaddrss);
		criteria.andJynameEqualTo(jyname);
		
		List<JiuyeGS> gs=jyGsDao.selectByExample(jiuyeGSExample);
		
		if(gs.size()>0){
			return gs.get(0);
		}
		
		return null;
	}

}
